function value = texture2D(I, y, x)

[dimY dimX] = size(I);
indexY = floor( (dimY-1)*y )+1;
indexX = floor( (dimX-1)*x )+1;
%rem mean get the fraction 
fracY = rem( (dimY-1)*y,1 );
fracX = rem( (dimY-1)*x,1 );

TL = getSample(I,indexY, indexX);
TR = getSample(I,indexY, indexX+1);
BL = getSample(I,indexY+1, indexX);
BR = getSample(I,indexY+1, indexX+1);

%bilinear interpolation
value = (TL*(1-fracX) + TR*fracX)*(1-fracY)+ (BL*(1-fracY) + BR*fracY)*fracY;
